<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>OA协同办公系统</title>
		<style type="text/css">
body,td,th {
	font-family: "宋体";
	font-size: 12px;
}
</style>
		<link type="text/css" rel="stylesheet" href="js/checktree/jquery.checktree.css" />
		<link type="text/css" rel="stylesheet" href="css/table.css" />
		<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
		<script type="text/javascript" src="js/checktree/jquery.checktree_yctin.min.js"></script>
		<script type="text/javascript">
var $checktree;
$(function(){
	var menus=$("input[type=\"checkbox\"]");
	var roleId=$("#roleId").val();
	var param={"roleId":roleId};
	$.post("menuRoleAll.action",param,function(data){
			var list=data.roleMenuList;
			for(var i=0;i<menus.length;i++){
				for(var j=0;j<list.length;j++){
					if(menus[i].value==list[j].menuId){
						menus[i].checked=true;
						break;
					}
				}
			}
			document.getElementById("tree").style.visibility="";
			$("#loading").hide();
			$checktree = $("ul.tree").checkTree();
	},"json");
});
	function selectMenu(){
		var roleId=$("#roleId").val();
		var param="roleId="+roleId;
		var menus=$("input[type=\"checkbox\"]");
		for(var i=0;i<menus.length;i++){
			if(menus[i].checked){
				param+="&menus="+menus[i].value;
			}
		}
		$.post("roleMenuRoot.action",param,function(data){
			if(data=='success'){
				alert("授权成功！")
			}else{
				alert("授权失败!");
			}
			window.close();
		});
	}
</script>
	</head>

	<body>
		<div class="AvidmDivLoading" id="loading">
			<span>请稍待，载入中……</span>
		</div>
		<input type="hidden" id="roleId" value="${roleId}">
		<table align="center">
			<tr>
				<td>
					<div class="roladiv">
						<h1 class="rolah1">权限分配</h1>
						<div id="tree-div" class="roladivbot">
							<ul class="tree" id="tree" style="overflow: auto; visibility: hidden;">
								${menuTree}
							</ul>
						</div>
					</div>
				</td>
			</tr>
			<tr>
				<td align="center">
					<input type="button" onclick="selectMenu()" class="button_04"  value="保存" />
					<input type="button" onclick="window.close()" class="button_04"  value="关闭" />
				</td>
			</tr>
		</table>
	</body>
</html>
